/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-05-04 09:50:21
 * @LastEditTime : 2023-07-11 08:26:06
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\Api.jsx
 * @Description  :
 */
import dayjs from 'dayjs'
import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton, OpenExcelButton, SelectExcelButton } from '../Common/options'
import { InvestListTreeConversion } from '../Common/Conversion'
export const InvestPlans = async ({ url, OptionsEvent, ClientData }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            <SelectExcelButton
                key="one"
                title="下载投资统计"
                OptionsEvent={OptionsEvent}
                api={API_LIST()['getInvestPlanExcel']}
            />,
            <OpenExcelButton
                key="two"
                title="批量导入"
                OptionsEvent={OptionsEvent}
                data={{
                    save: true,
                    submit: true,
                    url: 'getInvestPlanInfo',
                    pos: 'posUploadInvestPlans',
                }}
            />,
            <AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />,
        ],
        columns: [
            { ...commonTableList.SearchSort, selectType: 'InvestPlans' },
            commonTableList.uuid,
            // { ...commonTableList.tableName, title: '名称' },
            {
                dataIndex: 'eventDate',
                title: '日期',
                valueType: 'Date',
                ellipsis: true,
                rules: true,
                width: 200,
                hideInSearch: true,
                render: (_, e) => <div>{dayjs(e.eventDate).format('YYYY-MM-DD')}</div>,
            },
            {
                dataIndex: 'planType',
                title: '计划类型',
                valueType: 'select',
                valueEnum: { 总体: '总体', 年度: '年度', 月份: '月份' },
                ellipsis: true,
                rules: true,
                width: 200,
            },
            {
                dataIndex: 'investListUuid',
                title: '投资清单',
                valueType: 'treeSelect',
                fieldProps: {
                    options: await InvestListTreeConversion(),
                    fieldNames: { label: 'tableName', value: 'uuid' },
                },
                rules: true,
                width: 200,
            },
            {
                dataIndex: 'amount',
                title: '金额',
                valueType: 'inputNumber',
                ellipsis: true,
                rules: true,
                width: 200,
                hideInSearch: true,
            },
            { ...commonTableList.organizationUuid, valueEnum: ClientData.organization, rules: false },
            {
                dataIndex: 'remark',
                title: '备注',
                valueType: 'input',
                ellipsis: true,

                width: 200,
            },
            commonTableList.BeginStatDate,
            commonTableList.EndStatDate,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 160,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />,
                        <DelDataButton
                            OptionsEvent={OptionsEvent}
                            key="del"
                            title="删除"
                            url={url}
                            uuid={record.uuid}
                        />,
                    ]
                },
            },
        ],
    }

    return data
}
